home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C25 / Trash.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  661 b   |  23 lines

  1. //: C25:Trash.cpp {O}
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. #include "Trash.h"
  7. using namespace std;
  8.  
  9. Trash* Trash::factory(const Info& info) {
  10.   vector<Trash*>::iterator it;
  11.   for(it = prototypes.begin();
  12.     it != prototypes.end(); it++) {
  13.     // Somehow determine the new type
  14.     // to create, and clone one:
  15.     if (info.id() == (*it)->id())
  16.       return (*it)->clone(info);
  17.   }
  18.   cerr << "Prototype not found for "
  19.     << info << endl;
  20.   // "Default" to first one in the vector:
  21.   return (*prototypes.begin())->clone(info);
  22. } ///:~
  23.